package com.cyf.db.mapper;

import com.cyf.db.bean.LocalIctrechargerecord;
import com.cyf.db.bean.RedPacketRecord;
import com.cyf.smartCity.bean.RedPacketReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 现金找零 红包记录Mapper
 */
@Mapper
public interface RedPacketRecordMapper {

    /**
     * 查询全部红包记录
     */
    @Select("<script>" +
            " SELECT ict.id,ict.plate,ict.createdTime,ict.actualFee, " +
            "    ict.shouldFee,ict.changeAmount,ict.orderNumber,ict.receivingStatus, " +
            "    ict.parkingId " +
            "    FROM local_ict AS ict " +
            "where ict.changeAmount != 0 "+
            "<if test=\"req.parkingId != null and req.parkingId != ''\">" +
            "   and ict.parkingId = #{req.parkingId} " +
            "</if>" +
            "<if test=\"req.plate != null and req.plate != ''\">" +
            "   and ict.plate = #{req.plate} " +
            "</if>" +
            "<if test=\"req.createdStr != null and req.createdStr != ''\">" +
            "<![CDATA[ and ict.createdTime>='${req.createdStr} 00:00:00' ]]>" +
            "</if>" +
            "<if test=\"req.createdEnd != null and req.createdEnd != ''\">" +
            "<![CDATA[ and ict.createdTime<='${req.createdEnd} 23:59:59' ]]>" +
            "</if>" +
            "    order by ict.createdTime desc"+
            "</script>")
    List<RedPacketRecord> listRedPacketRecord(@Param("req") RedPacketReq req);


    @Select("<script>" +
            "select * from local_ictrechargerecord " +
            "<where>  " +
            "<if test=\"req.parkingId != null and req.parkingId != ''\">" +
            "   and parkingId = #{req.parkingId} " +
            "</if>" +
            "<if test=\"req.createdStr != null and req.createdStr != ''\">" +
            "<![CDATA[ and createdTime>='${req.createdStr} 00:00:00' ]]>" +
            "</if>" +
            "<if test=\"req.createdEnd != null and req.createdEnd != ''\">" +
            "<![CDATA[ and createdTime<='${req.createdEnd} 23:59:59' ]]>" +
            "</if>" +
            "</where>  " +
            "</script>")
    List<LocalIctrechargerecord> redPacketRechargeList(@Param("req")RedPacketReq req);
}
